package com.wordpress.minhnvt1.simpleframework.domain;

import java.util.ArrayList;
import java.util.List;

import org.simpleframework.xml.Attribute;
import org.simpleframework.xml.Default;
import org.simpleframework.xml.DefaultType;
import org.simpleframework.xml.Root;
import org.simpleframework.xml.core.Persist;

@Root
@Default(DefaultType.FIELD)
public class Organization {
	private String 			name;
	private Address			address;
	private List<Person>	staff = new ArrayList<Person>();
	@Attribute
	private int 			count;
	public Organization() {}
	public Organization(String name, Address address) {
		this.name = name;
		this.address = address;
	}
	public void add(Person person) {
		staff.add(person);
	}
	public String getName() {
		return name;
	}
	public Address getAddress() {
		return address;
	}
	public List<Person> getListPerson() {
		return staff;
	}
	public int getCount() {
		return staff.size() + 2;
	}
	@Persist
	public void prepare() {
		count = getCount();
	}
	@Override
	public String toString() {
        final StringBuilder sb = new StringBuilder();
        sb.append("Organization");
        sb.append("{name='").append(name).append('\'');
        sb.append(", address=").append(address);
        sb.append(", staff=").append(staff);
        sb.append('}');
        return sb.toString();
    }
}
